<template>
  <div class="card-header">
    <div class="head-title">{{headerData.title}}</div>
    <div class="head-explain">
      操作说明
      <i class="el-icon-question"></i>
    </div>
    <div class="head-button" v-if="headerData.buttonName">
      <el-button type="warning" @click="buttonClick">{{headerData.buttonName}}</el-button>
    </div>

    <div class="head-button" v-for="(button,index) in headerData.buttonList" :key="index">
      <el-button :type="button.type" @click="buttonClick">{{button.name}}</el-button>
    </div>

    <div class="head-form" v-if="headerData.module">
      <span class="demonstration">{{headerData.module.title}}:</span>
      <el-date-picker v-model="dataTimeValue" type="datetime" placeholder="选择日期时间" value-format=" yyyy-MM-dd"
                      format="yyyy-MM-dd" v-if="headerData.module.type == 'datetime'"
                      @change="dataTimeChange"></el-date-picker>
    </div>
  </div>
</template>

<script>
  export default {
    name: "cardHeader",
    data() {
      return {
        dataTimeValue: ''
      }
    },
    props: {
      headerData: {
        type: Object,
        default: () => {
        }
      }
    },
    methods: {
      buttonClick() {
        this.$emit('buttonClick', '')
      },
      dataTimeChange() {
        this.$emit('dataTimeChange', this.dataTimeValue);
      }
    }
  };
</script>

<style lang="scss">
  .card-header {
    background: #f5f5f5;
    height: 45px;
    line-height: 45px;
    padding: 0 10px;
    font-weight: 600;
  }

  .head-title {
    color: rgb(2, 2, 2);
    text-align: left;
    display: inline;
  }

  .head-explain {
    color: #333;
    text-align: left;
    display: inline;
    font-size: 14px;
    margin-left: 5px;
  }

  .head-button {
    margin-left: 12px;
    float: right;
  }

  .head-form {
    float: right;
    margin-right: 16px;
  }
</style>
